<?php


namespace App\Helpers\Traits;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
trait ApiResponse
{
    public function success($data=null,string $message="获取数据成功",int $statusCode=Response::HTTP_OK):JsonResponse{
        return response()->json([
            'success' => true,
            'message' => $message,
            'data'=>$data,
        ],$statusCode);
    }

    public function failed($message="获取数据失败",int $statusCode=200){
        return response()->json([
            'success' => false,
            'message' => $message,
            'data'=>null,
        ],$statusCode);
    }
}
